#include<cstdio>
#include<vector>
#include<time.h>
template <typename T>
void swap(T &el1, T &el2)
{
T buff = el2;
el2 = el1;
el1 = buff;
}
std::vector<int> bubble_sort(std::vector<int> arr)
{
int n = arr.size() - 1;
bool swapped;
for (int i = 0; i < n; i++) 
{
for (int j = 0; j < n - i; j++) 
{
if (arr[j] > arr[j + 1]) swap(arr[j], arr[j + 1]); 
}
}
return arr;
}
void run(const char * fname, int nums)
{
clock_t start, end;
auto f = fopen(fname, "r");
std::vector<int> arr(nums, nums);
for (auto &el : arr) fscanf(f, "%d", &el);
start = clock();
arr = bubble_sort(arr);
end = clock();
double res = ((double) (end - start)) / CLOCKS_PER_SEC * 1000;
printf("%s %d milliseconds\n", fname, (int) res);
}
int main()
{
run("m1_sorted.txt", 5000);
run("m2_reverse.txt", 5000);
run("m3_shuffle.txt", 5000);
return 0;
}
